home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 14 / CU Amiga Magazine's Super CD-ROM 14 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-09].iso / CUCD / Programming / GMS / Source / Asm / Screens / ResizeWorm.s < prev    next >
Encoding:
Text File  |  1997-05-04  |  5.9 KB  |  287 lines

  1. ;-------T-------T------------------------T----------------------------------;
  2. ;Picture Resizing
  3. ;----------------
  4. ;This version of the Worm demo opens a 640x512 screen and resizes the 320x256
  5. ;background to fit this screen mode.  Then it blits the worm on top, which
  6. ;appears at half its normal size because of the change of resolution.
  7. ;
  8. ;You can change the resolution if you like, just edit the settings below.
  9.  
  10. SCREENWIDTH =    640    ;Factor of 16
  11. SCREENHEIGHT =    512
  12.  
  13.     INCDIR    "INCLUDES:"
  14.     INCLUDE    "games/games_lib.i"
  15.     INCLUDE    "games/games.i"
  16.  
  17. CALL    MACRO
  18.     jsr    _LVO\1(a6)
  19.     ENDM
  20.  
  21.     SECTION    "Resize",CODE
  22.  
  23. ;===========================================================================;
  24. ;                             INITIALISE DEMO
  25. ;===========================================================================;
  26.  
  27.     STARTGMS
  28.  
  29. Start:    MOVEM.L    A0-A6/D1-D7,-(SP)
  30.     move.l    GMSBase(pc),a6    ;Activate user preferences.
  31.     CALL    AllocBlitter
  32.     tst.l    d0
  33.     bne    .Error_Blitter
  34.  
  35.     CALL    AllocAudio
  36.     tst.l    d0
  37.     bne    .Error_Audio
  38.  
  39.     lea    ScreenTags(pc),a0    ;Initialise the screen.
  40.     CALL    AddScreen
  41.     tst.l    d0
  42.     beq    .Error_Screen
  43.  
  44. ;---------------------------------------------------------------------------;
  45. ;Load a picture into the background of the screen.  We have to set the
  46. ;correct palette and copy it to our second buffer as part of this process.
  47.  
  48.     move.l    Screen(pc),a0
  49.     lea    PIC_BackgroundTags(pc),a1
  50.     move.l    GS_MemPtr2(a0),Data
  51.     CALL    LoadPic
  52.     tst.l    d0
  53.     beq.s    .Error_Picture
  54.  
  55.     move.l    PIC_Background(pc),a1
  56.     move.l    PIC_Palette(a1),GS_Palette(a0)
  57.     CALL    UpdatePalette
  58.  
  59.     move.l    Screen(pc),a0
  60.     CALL    SwapBuffers
  61.     moveq    #BUFFER1,d0
  62.     moveq    #BUFFER2,d1
  63.     CALL    CopyBuffer
  64.  
  65. ;---------------------------------------------------------------------------;
  66. ;Initialise the restorelist.
  67.  
  68.     moveq    #2,d0    ;2 buffers.
  69.     moveq    #1,d1    ;1 BOB Entry.
  70.     CALL    InitRestore
  71.     move.l    d0,RestoreList
  72.     beq.s    .Error_RestoreList
  73.  
  74. ;---------------------------------------------------------------------------;
  75. ;Load the bob file in.  This contains the graphics data that we are going to
  76. ;draw to the screen.
  77.  
  78.     move.l    Screen(pc),a0    ;Initialise the BOB so that it is
  79.     lea    BBT_Rambo(pc),a1    ;ready for drawing.
  80.     CALL    InitBob
  81.     tst.l    d0
  82.     beq.s    .Error_Bob
  83.  
  84.     lea    SMT_Rambo(pc),a0
  85.     CALL    InitSound
  86.     tst.l    d0
  87.     beq.s    .Error_Sound
  88.  
  89.     move.l    Screen(pc),a0
  90.     CALL    ShowScreen
  91.  
  92.     bsr.s    Main
  93.  
  94. .ReturnToDOS
  95.     move.l    GMSBase(pc),a6
  96.     move.l    SND_Rambo(pc),a0
  97.     CALL    FreeSound
  98. .Error_Sound
  99.     move.l    BOB_Rambo(pc),a1
  100.     CALL    FreeBob
  101. .Error_BOB
  102.     move.l    RestoreList(pc),d0
  103.     CALL    FreeRestore
  104. .Error_RestoreList
  105.     move.l    PIC_Background(pc),a1
  106.     CALL    FreePic
  107. .Error_Picture
  108.     move.l    Screen(pc),a0
  109.     CALL    DeleteS creen
  110. .Error_Screen
  111.     CALL    FreeAudio
  112. .Error_Audio
  113.     CALL    FreeBlitter
  114. .Error_Blitter
  115.     MOVEM.L    (SP)+,A0-A6/D1-D7
  116.     moveq    #ERR_OK,d0
  117.     rts
  118.  
  119. ;===========================================================================;
  120. ;                                MAIN LOOP
  121. ;===========================================================================;
  122.  
  123. SPEED    =    5
  124. FIRESPEED =    0
  125.  
  126. Main:    move.l    GMSBase(pc),a6
  127.     CALL    InitJoyPorts
  128.     moveq    #$00,d7
  129.  
  130. .Loop    move.l    Screen(pc),a0
  131.     move.l    RestoreList(pc),a1
  132.     CALL    Restore
  133.  
  134.     move.l    BOB_Rambo(pc),a1
  135.     move.l    RestoreList(pc),a2
  136.     moveq    #BUFFER2,d0
  137.     CALL    DrawBOB    ;Blit the bob.
  138.     CALL    WaitVBL    ;Wait for VBL.
  139.     CALL    SwapBuffers
  140.     addq.w    #1,d7
  141.  
  142.     tst.b    FireState
  143.     bne.s    .FireOn
  144.  
  145.     cmp.w    #SPEED,d7
  146.     ble.s    .Move
  147.     moveq    #$00,d7
  148.     addq.w    #1,BOB_Frame(a1)
  149.     cmp.w    #9,BOB_Frame(a1)
  150.     blt.s    .Move
  151.     clr.w    BOB_Frame(a1)
  152.     bra.s    .Move
  153.  
  154. .FireOn    cmp.w    #FIRESPEED,d7
  155.     ble.s    .Move
  156.     moveq    #$00,d7
  157.     cmp.w    #10,BOB_Frame(a1)
  158.     bge.s    .On
  159.     move.w    #9,BOB_Frame(a1)
  160.  
  161. .On    addq.w    #1,BOB_Frame(a1)
  162.     cmp.w    #13,BOB_Frame(a1)
  163.     blt.s    .Move
  164.  
  165.     move.l    SND_Rambo(pc),a0
  166.     CALL    PlaySound
  167.  
  168.     btst    #MB_LMB,d0
  169.     beq.s    .Off
  170.     move.w    #11,BOB_Frame(a1)
  171.     bra.s    .Move
  172.  
  173. .Off    clr.w    BOB_Frame(a1)
  174.     clr.b    FireState
  175.  
  176. .Move    moveq    #JPORT1,d0    ;Read the mouse, then update the
  177.     moveq    #JT_ZBXY,d1    ;BOB's X and Y co-ordinates.
  178.     CALL    ReadJoyPort
  179.     move.w    d0,d1
  180.     ext.w    d0
  181.     add.w    d0,BOB_YPos(a1)
  182.     asr.w    #8,d1
  183.     add.w    d1,BOB_XPos(a1)
  184.  
  185.     btst    #MB_LMB,d0
  186.     beq.s    .chkRMB
  187.     st    FireState    ;Set fire to on.
  188. .chkRMB    btst    #MB_RMB,d0
  189.     beq    .Loop
  190.     rts
  191.  
  192. FireState:
  193.     dc.b    0
  194.     even
  195.  
  196. ;===========================================================================;
  197. ;                                  DATA
  198. ;===========================================================================;
  199.  
  200. SCREENMODE =    HIRES|LACED
  201. SCREENPLANES =    5
  202. SCREENTYPE =    ILBM
  203.  
  204. RestoreList:    dc.l  0
  205.  
  206. ScreenTags:
  207.     dc.l    TAGS_GAMESCREEN
  208. Screen:    dc.l    0
  209.     dc.l    GSA_ScrWidth,SCREENWIDTH
  210.     dc.l    GSA_ScrHeight,SCREENHEIGHT
  211.     dc.l    GSA_Planes,SCREENPLANES
  212.     dc.l    GSA_Attrib,DBLBUFFER|CENTRE
  213.     dc.l    GSA_ScrMode,SCREENMODE
  214.     dc.l    GSA_ScrType,SCREENTYPE
  215.     dc.l    TAGEND
  216.  
  217. PIC_BackgroundTags:
  218.     dc.l    TAGS_PICTURE
  219. PIC_Background:
  220.     dc.l    0
  221.     dc.l    PCA_Data
  222. Data:    dc.l    0
  223.     dc.l    PCA_Width,SCREENWIDTH
  224.     dc.l    PCA_Height,SCREENHEIGHT
  225.     dc.l    PCA_Planes,SCREENPLANES
  226.     dc.l    PCA_ScrMode,SCREENMODE
  227.     dc.l    PCA_Options,GETPALETTE|RESIZE
  228.     dc.l    PCA_File,.file
  229.     dc.l    PCA_ScrType,SCREENTYPE
  230.     dc.l    TAGEND
  231. .file    dc.b    "GMS:demos/data/PIC.Green",0
  232.     even
  233.  
  234. ;---------------------------------------------------------------------------;
  235.  
  236. BBT_Rambo:
  237.     dc.l    TAGS_BOB
  238. BOB_Rambo:
  239.     dc.l    0
  240.     dc.l    BBA_Framelist,.frames
  241.     dc.l    BBA_Width,32
  242.     dc.l    BBA_Height,24
  243.     dc.l    BBA_XCoord,50
  244.     dc.l    BBA_YCoord,50
  245.     dc.l    BBA_Attrib,GENMASKS|CLIP|RESTORE
  246.     dc.l    BBA_PictureTags,.picture
  247.     dc.l    TAGEND
  248.  
  249. .frames    dc.w    000,00,0,0   ;0 X/Y Graphic, X/Y Mask
  250.     dc.w    032,00,0,0   ;1 ...
  251.     dc.w    064,00,0,0   ;2
  252.     dc.w    096,00,0,0   ;3
  253.     dc.w    128,00,0,0   ;4
  254.     dc.w    160,00,0,0   ;5
  255.     dc.w    192,00,0,0   ;6
  256.     dc.w    224,00,0,0   ;7
  257.     dc.w    256,00,0,0   ;8
  258.     dc.w    288,00,0,0   ;9
  259.     dc.w    000,48,0,0   ;10
  260.     dc.w    032,48,0,0   ;11
  261.     dc.w    064,48,0,0   ;12
  262.     dc.l    -1
  263. .picture
  264.     dc.l    TAGS_PICTURE,0
  265.     dc.l    PCA_Planes,5
  266.     dc.l    PCA_Options,BLITMEM
  267.     dc.l    PCA_File,.file
  268.     dc.l    PCA_ScrType,SCREENTYPE
  269.     dc.l    TAGEND
  270.  
  271. .file    dc.b    "GMS:demos/data/PIC.Rambo",0
  272.     even
  273.  
  274. SMT_Rambo:
  275.     dc.l    TAGS_SOUND
  276. SND_Rambo:
  277.     dc.l    0
  278.     dc.l    SA_Channel,CHANNEL1
  279.     dc.l    SA_Octave,OCT_C2S
  280.     dc.l    SA_Volume,100
  281.     dc.l    SA_File,.file
  282.     dc.l    TAGEND
  283.  
  284. .file    dc.b    "GMS:demos/data/SND.Rambo",0
  285.     even
  286.  
  287.